<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>添加商品</title>
    <link rel="stylesheet" href="../../style/brand/addbrand.css">
    <link rel="stylesheet" href="../../libs/bootstrap-5.3.0-alpha1-dist/css/bootstrap.css">
    <script src="../../js/vue-2.6.12.js"></script>
    <script src="../../js/axios-0.21.0.js"></script>
    <script src="../../js/qs-6.9.4.js"></script>
    <script src="../../js/vue-router-3.4.9.js"></script>
</head>

<body>
    <div class="containers" id="app">
        <h3>商品</h3>
        <hr>
        <div class="container-basic">
            <h2>添加商品</h2>
            <form class="form-inline">
                <div class="row g-3 align-items-center">
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="add-ename">商品名:</label>
                            <input type="text" class="form-control" placeholder="商品" v-model="goods.goodsName">
                        </div>
                    </div>
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="add-ename">库存:</label>
                            <input type="text" class="form-control" placeholder="库存"  v-model="goods.stock">
                        </div>
                    </div>
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="add-ename">进货价:</label>
                            <input type="text" class="form-control" placeholder="进货价"  v-model="goods.costPrice">
                        </div>
                    </div>
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="add-ename">单价:</label>
                            <input type="text" class="form-control" placeholder="单价" v-model="goods.retailPrice">
                        </div>
                    </div>
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="add-ename">折扣:</label>
                            <input type="text" class="form-control" placeholder="折扣" v-model="goods.discount">
                        </div>
                    </div>
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="">状态</label>
                            <select class="form-control" style="width: 200px;"  v-model="goods.status">
                                <option value="1">启用</option>
                                <option value="0">禁用</option>

                            </select>
                        </div>
                    </div>
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="">类别</label>
                            <select class="form-control" style="width: 200px;" v-model="goods.categoryId">
                                <option value="1">衣服</option>
                                <option value="2">鞋子</option>
                                <option value="3">项链</option>
                                <option value="4">包包</option>
                                <option value="5">娃娃</option>
                                <option value="6">汽车</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="add-ename">上架时间:</label>
                            <input type="date" class="form-control" style="width: 200px;" v-model="goods.listTime">

                        </div>
                    </div>
                   
                    <div class="col-auto">
                        <div class="form-group">
                            <label for="inputEmail3" class="control-label">商品介绍:</label>
                            <textarea class="form-control" rows="3" cols="65" style="vertical-align: middle;" v-model="goods.introduction"></textarea>
                        </div>
                    </div>
                </div>
            </form>

            <button type="button" class="btn btn-primary" @click="addGood">添加</button>
        </div>
    </div>
<script>
    const app = new Vue({
        el:"#app",
        data:{
            goods:{}
        },
        methods:{
           addGood(){
               axios.post("/shop/goods/addGood",Qs.stringify(this.goods)).then(res=> {
                   if (res.data){
                       alert("添加成功")
                       location.href="/shop/views/brand/index.html";
                   }else {
                       alert("添加失败")
                   }
               }).catch(e=>{
                   alert("添加失败")
               })
           }
        },
    })
</script>
</body>



</html>